<?php

	/**
	 * 스타의 직업명으로 해당하는 아이콘명을 찾아준다.
	 */
	function get_star_job_icon($star_job) {

		$arr_star_job = explode(',', $star_job);
				
		$job_list['actor']      = array('영화배우', '영화감독', '영화인', '영화제작자', '영화촬영감독');
		$job_list['gag']        = array('개그맨', '코미디언');
		$job_list['sports']     = array('운동선수', '스케이트선수', '농구선수', '야구선수', '카레이서', '축구선수', '골프선수', '프로야구 선수');
		$job_list['mc']         = array('MC', 'VJ', '방송인', '아나운서');
		$job_list['misskorea']  = array('미스코리아', '모델');
		$job_list['musical']    = array('뮤지컬배우', '연극배우');
		$job_list['politician'] = array('국회의원', '공무원', '금융인', '기업인', '대학교수', '교수', '문화기관단체인', '연세대 교회음악과 교수', '정당인');
		$job_list['singer']     = array('가수', '바이올리니스트', '대중음악작곡가', '성악가', 'DJ', '국립합창단 예술감독', '음악PD', '오페라가수', '음악감독', '작곡가', '작사가', '지휘자', '첼리스트');
		$job_list['talent']     = array('탤런트', '방송연예인', '연예인');
		$job_list['and']        = array('그밖에', '방송작가', '사진작가', 'PD', '만화가', '공연기획자', '연예기획자', '작가', '촬영감독');
		
		foreach ($arr_star_job as $value) {
			$value = trim($value);
			
			foreach ($job_list as $key => $item) {
				if (in_array($value, $item)) {
					return $key;
				}
			}
		}
		
		return 'and';
	}

	include_once "db_connect.php";

	// 쿼리문 작성
	$sql  = " SELECT ";
	$sql .= "       idx ";
	$sql .= "     , artist_name ";
	$sql .= "     , job ";
	$sql .= "     , birth_yyyy ";
	$sql .= "     , birth_mm ";
	$sql .= "     , birth_dd ";
	$sql .= "     , sex ";
	$sql .= "     , body ";
	$sql .= "     , photo ";
	$sql .= " FROM  tb_artist ";
	$sql .= " WHERE birth_mm = '".date("m",time())."' ";
	$sql .= " AND   birth_dd = '".date("d",time())."' ";
	$sql .= " ORDER BY idx DESC ";
	
	$result_list = query_to_array($sql);
	
	foreach ($result_list as &$star) {
		$star['job_icon'] = get_star_job_icon($star['job']);
	}

	shuffle($result_list);
?>
				<form name="frm_starsearch" id="frm_starsearch" method="post" action="/unse/star/todaybirth/main#search">
					<input type="hidden" name="search_keyword" value="수영">
				</form>

				<div class="tostar">
					<h3><img src="/images/sub/common/tit_star.gif" alt="나와같은운명의스타"></h3>
                    <span class="more"><a href="/unse/star/total/main">더보기</a></span>
					<ul>
<?
	$limit = count($result_list) < 3 ? count($result_list) : 3;
	for ($i=0; $i < $limit; $i++) {
		$item = $result_list[$i];
?>
						<li class="to">
							<dl>
								<dt class="img"><a href="javascript:;" onclick="document.frm_starsearch.search_keyword.value='<?=$item['artist_name']?>';document.frm_starsearch.submit()"><img src="<?=$item['photo']?>" width="36" height="36"  alt="스타사진" /></a></dt>
								<dd>이름 / <em><a href="javascript:;" onclick="document.frm_starsearch.search_keyword.value='<?=$item['artist_name']?>';document.frm_starsearch.submit()"><?=$item['artist_name']?><span>(<?=$item['birth_yyyy']?>년생)</span></a></em></dd>
								<dd>직업 / <em><?=$item['job']?></em></dd>
							</dl>
						</li>
<?	} ?>
					</ul>
				</div>
